You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
636 B

import { delCache } from "#server/utils/context";
import { deleteCard, getCardById } from "../../service/card";
export default defineWrappedResponseHandler(async (event) => {
const idParam = getRouterParam(event, "id");
if (!idParam) return R.throwError(400, "缺少卡片 ID", null);
const id = parseInt(idParam);
if (isNaN(id)) return R.throwError(400, "卡片 ID 格式不正确", null);
const existing = await getCardById(id);
if (!existing) return R.throwError(404, "卡片不存在", null);
await deleteCard(id);
await delCache(`card:${id}`);
await delCache("categories:tree");
return R.success(null);
});